﻿using System;
using System.Configuration;
using System.Data;
using System.Globalization;

using BizElements.Core;

namespace BizElements.BusinessLayer
{
    /// <summary>
    /// <see cref="LockManager"/> specialization which uses default table for all object types.
    /// </summary>
    /// <remarks>Default table and database which contains is specified in application's config file:
    /// <code>
    /// <configuration>
    ///     <appSettings>
    ///         <add key="BizElements.BusinessLayer.DefaultLockManager.DbmsType" value="SqlServer_2008" />
    ///         <add key="BizElements.BusinessLayer.DefaultLockManager.TableName" value="LockManager" />
    ///     </appSettings>
    ///     <connectionStrings>
    ///         <add name="BizElements.BusinessLayer.DefaultLockManager.ConnectionString" connectionString="data source=.;initial catalog=MementoDatabase;integrated security=SSPI;persist security info=False;packet size=4096" />
    ///     </connectionStrings>
    /// </configuration>
    /// </code>
    /// </remarks>
    [Serializable]
    public sealed class DefaultLockManager : LockManager
    {
        /// <summary>
        /// Initializes a new instance of DefaultLockManager class.
        /// </summary>
        public DefaultLockManager()
        {
            LockManagerMeta table = new LockManagerMeta();
            Init(table, table.ObjectType, new IDbColumn[] { table.ObjectId }, table.LockedBy, table.LockedTill, table.LockMode, false, null, null);
        }
    }
}